//
//  IconSelectionCell.swift
//  HLDesktop
//
//  Created by 黄龙 on 2023/9/4.
//

import UIKit

class IconSelectionCell: UICollectionViewCell {
    lazy var mImage: UIImageView = {
        let mImage = UIImageView()
        mImage.image = UIImage(systemName: "photo.on.rectangle.angled")?.withTintColor(.secondaryLabel,renderingMode: .alwaysOriginal)
        return mImage
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        let backView = UIView(frame: CGRect(x: 5, y: 5, width: self.bounds.width-10, height: self.bounds.height-10))
        self.addSubview(backView)
        backView.layer.cornerRadius = 10
        backView.backgroundColor = .secondarySystemBackground
        
        self.addSubview(self.mImage)
        self.mImage.frame = CGRect(x: 20, y: 20, width: self.bounds.width-40, height: self.bounds.height-40)
    }
    
    func updateCellColor(_ bgColor:UIColor){
        self.backgroundColor = bgColor
    }
    
    func updateCellImg(systemImgName:String){
        self.mImage.image = UIImage(systemName: systemImgName)?.withTintColor(.secondaryLabel,renderingMode: .alwaysOriginal)
    }
    
    func showBigImg(){
        self.mImage.frame = CGRect(x: 10, y: 10, width: self.bounds.width-20, height: self.bounds.height-20)
    }
    
    func showSmallImg(){
        self.mImage.frame = CGRect(x: 20, y: 20, width: self.bounds.width-40, height: self.bounds.height-40)
    }
}
